package edu.sctu.zhengsenwen.month201505.day20150529;

import java.util.Scanner;
import java.util.HashMap;
/**
 * Created by user15 on 2015/5/29.
 */
public class OwnHashMap{

    HashMap<String,Teacher>  hashMap = new HashMap<String,Teacher>();

    Scanner input = new Scanner(System.in);


    public void setHashMap() {

        for (int check = 0;check == 0;check = input.nextInt()) {

            Teacher teacher = new Teacher();
            System.out.println("请输入你的姓名：");
            teacher.name = input.next();
            System.out.println("请输入你的年龄：");
            teacher.age = input.nextInt();
            System.out.println("请输入你的所教课程：");
            teacher.course = input.next();

            hashMap.put(teacher.name,teacher);

            System.out.println("输入 0 时继续添加数据，输入其它任意键则停止添加数据");
        }

    }

    public void printMap(){

        System.out.println("下面是输出信息：");

        System.out.println(hashMap.keySet());

        System.out.println("选择你要查看的老师的信息：");

        String teacherName = input.next();

        System.out.println("该老师所教的课程：\t"+hashMap.get(teacherName).name+"\t"+"该老师的年龄：\t"+hashMap.get(teacherName).age+"\t"+"该老师所教的课程：\t"+hashMap.get(teacherName).course);
    }



}
